package com.neusoft.neuiotms.dcvm.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONArray;
import com.neusoft.bizcore.web.dto.result.ResultDTO;
import com.neusoft.neuiotms.dcvm.service.StatisticService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api("租赁业务管理")
@RestController
@RequestMapping(value = "/api/w/leaseBusiness")
public class LeaseBusinessController {

    @Autowired
    private StatisticService statisticService;

    @ApiOperation("根据位置获取客户列表")
    @GetMapping("/customs/{PosCode}")
    public ResultDTO<?> getLBCustoms(@PathVariable final String PosCode) {
        final JSONArray result = this.statisticService.getLBCustoms(PosCode);
        if (result == null) {
            return ResultDTO.failure();
        }
        return ResultDTO.success(result);
    }

    @ApiOperation("根据位置获取业务列表")
    @GetMapping("/indents/{PosCode}")
    public ResultDTO<?> getLBIndents(@PathVariable final String PosCode) {
        final JSONArray result = this.statisticService.getLBIndents(PosCode);
        if (result == null) {
            return ResultDTO.failure();
        }
        return ResultDTO.success(result);
    }

    @ApiOperation("根据位置获取机柜内租赁详情分布")
    @GetMapping("/rackLeaseDetail/{PosCode}")
    public ResultDTO<?> getLBDetail(@PathVariable final String PosCode) {
        final JSONArray result = this.statisticService.getLBDetail(PosCode);
        if (result == null) {
            return ResultDTO.failure();
        }
        return ResultDTO.success(result);
    }

}
